//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System;
using System.Linq.Expressions;
using EntLibContrib.Query.Queries;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel;

namespace EntLibContrib.Query.Configuration
{
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Design;

    /// <summary>
	/// Configuration data defining WebServiceQueryData.
	/// </summary>    
    [ResourceDescription(typeof(DesignResources), "WebServiceQueryDataDescription")]
    [ResourceDisplayName(typeof(DesignResources), "WebServiceQueryDataDisplayName")]
    public class WebServiceQueryData : ServiceQueryData
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="WebServiceQueryData"/> class.
		/// </summary>
		public WebServiceQueryData ()
		{
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="WebServiceQueryData"/> class.
		/// </summary>
		/// <param name="name">The name of the <see cref="WebServiceQueryData"/>.</param>
		/// <param name="customCommandName">Name of the custom command.</param>
		/// <param name="parameterSetName">Name of the parameter set.</param>
		/// <param name="address">The service address.</param>
		/// <param name="service">The service type name.</param>
		/// <param name="method">The service method.</param>
		public WebServiceQueryData(string name, string customCommandName, string parameterSetName, string address, string service, string method)
			: base(name, typeof(WebServiceQuery), customCommandName, parameterSetName, address, service, method)
		{
		}

        /// <summary>
        /// Returns the <see cref="TypeRegistration"/> entry for the current concrete type represented by this 
        /// configuration object.
        /// </summary>
        /// <returns>A registry entry.</returns>
        protected override Expression<Func<IQuery>> GetQueryCreationExpression()
        {
            return () =>
                   new WebServiceQuery(
                       Name,
                       Address,
                       Service,
                       Method,
                       Container.ResolvedIfNotNull<ICommand>(CustomCommandName),
                       Container.ResolvedIfNotNull<IParameterSet>(ParameterSetName));
        }
	}
}